<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8" >
    <title>登录</title>

</head>
<body>
<h3>登录</h3>
账号：<input type="text" name="name" id="name"><br>
密码：<input type="password" name="password" id="password"><br>
<button onclick="login()">登录</button>

<script type="text/javascript" src="../static/js/jquery.js"></script>
<script type="text/javascript">
    function login() {
        var name=$("#name").val();
        var password=$("#password").val();
        $.ajax({
            url:"http://localhost:8080/login",
            type:'post',
            data:{
                name:name,
                password:password
            },
            success:function (res){
                if(res===1){
                    alert("登录成功");
                }else if(res===2){
                    $("#password").val("");
                    alert("密码不正确");
                }else{
                    window.location.href = 'http://localhost:8080/registered';
                }
            }
        })

    }
</script>
</body>
</html>